package common.interfaces;

import java.sql.SQLException;

import user.User;

import common.exceptions.ExistingEntityException;

/**
 * A class whose role it is to manage the registration and persistence of user and their passwords
 * 
 * @author Gal Lalouche
 * 
 */
public interface IUserRegisteryManager extends IDAL<User, String> {
	
	/**
	 * Check if a given username and a password match
	 * 
	 * @param username The username to check
	 * @param password The password to check
	 * @return {@code true} iff an existing username exists in the system and the password matches the user
	 * @throws SQLException
	 */
	boolean isPasswordOf(String username, String password) throws SQLException;
	
	/**
	 * Registers a user to the system
	 * 
	 * @param requestedUsername The user's requested username
	 * @param name The user's selected name
	 * @param requestedPassword The user's requested password
	 * @throws ExistingEntityException If the username is already in use
	 * @throws SQLException
	 */
	void registerUser(String requestedUsername, String name, String requestedPassword) throws ExistingEntityException,
			SQLException;
	
	/**
	 * Register an admin to the system
	 * 
	 * @param requestedUsername The user's requested username
	 * @param name The user's selected name
	 * @param requestedPassword The user's requested password
	 * @throws ExistingEntityException If the username is already in use
	 * @throws SQLException
	 */
	void registerAdmin(String requestedUsername, String name, String requestedPassword) throws ExistingEntityException,
			SQLException;
	
	/**
	 * Removes a user from the system
	 * 
	 * @param username The user to remove
	 * @return {@code true} iff the user was successfully unregistered
	 * @throws SQLException
	 */
	boolean unregisterUser(String username) throws SQLException;
	
	/**
	 * @param password The password to check
	 * @return {@code true} iff the password is valid admin password
	 */
	boolean checkAdminPassword(String password);
}
